package com.ruoyi.project.men.service.impl;


import com.ruoyi.common.utils.bootdo.R;
import com.ruoyi.project.men.dao.MenProtocolClassDao;
import com.ruoyi.project.men.dao.MenProtocolInfoDao;
import com.ruoyi.project.men.domain.MenProtocolClassDO;
import com.ruoyi.project.men.service.MenProtocolClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class MenProtocolClassServiceImpl implements MenProtocolClassService {
	@Autowired
	private MenProtocolClassDao menProtocolClassDao;
	@Autowired
	private MenProtocolInfoDao menProtocolInfoDao;
	
	@Override
	public MenProtocolClassDO get(String id){
		return menProtocolClassDao.get(id);
	}
	
	@Override
	public List<MenProtocolClassDO> list(Map<String, Object> map){
		return menProtocolClassDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return menProtocolClassDao.count(map);
	}
	
	@Override
	public int save(MenProtocolClassDO menProtocolClass){
		return menProtocolClassDao.save(menProtocolClass);
	}
	
	@Override
	public int update(MenProtocolClassDO menProtocolClass){
		return menProtocolClassDao.update(menProtocolClass);
	}
	
	@Override
	public int remove(String id){
		return menProtocolClassDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return menProtocolClassDao.batchRemove(ids);
	}

    @Override
    public List<MenProtocolClassDO> likeList(Map<String, Object> map){
        return menProtocolClassDao.likeList(map);
    }
    @Override
    public int likeListCount(Map<String, Object> map){
        return menProtocolClassDao.likeListCount(map);
    }

	@Override
	public List<Map<String, Object>> queryAllForIdAndName(Map<String, Object> map) {

		return menProtocolClassDao.queryAllForIdAndName(map);
	}

    @Override
    public R getTrotocolClassList(Map<String, Object> map) {
		List<Map<String,Object>> classList=menProtocolClassDao.getTrotocolClassList(map);
		if(classList.size()>0){
			for (Map<String, Object> stringObjectMap : classList) {
				Map<String,Object> classMap = new HashMap<>();
				classMap.put("classId",stringObjectMap.get("id").toString());
				List<Map<String, Object>> trotocolInfoByClassId = menProtocolInfoDao.getTrotocolInfoByClassId(classMap);
				stringObjectMap.put("children",trotocolInfoByClassId);
			}
		}
		return R.ok().put("data",classList);
    }

}
